Recurse all items in database

Recursing all items in the database is not that simple.

 

There is the  'project in database' loop (all projects)

Then sub-loop for item in project (which is recursive)

 

or there is the folder in database loop (top level only projects)

which could be made recursive with a sub-loop for modules in folder

 

There is no simple 'for item in database' to loop through all the items in the database (projects/folders/modules)

 

Or is there?

Sean


DoorsXLAustralia - Fri Jun 05 00:26:01 EDT 2015

Re: Recurse all items in database
O.Wilkop - Fri Jun 05 07:20:53 EDT 2015

There is no simple form of that, no. But you can easily use the "for item in folder" loop and use it recursively:

void traverse(Folder f){
        Item i;
        for i in f do{
                if(type(i) == "Folder" || type(i) == "Project"){
                        traverse(folder(i));
                }

                if(type(i) == "Folder"){
                        // Do folder things
                }
                if(type(i) == "Project"){
                        // Do project things
                }
                if(type(i) == "Formal"){
                        // Do formal module things
                }
                if(type(i) == "Descriptive"){
                        // Do descriptive module things
                }
                if(type(i) == "Link"){
                        // Do link module things
                }
        }
}

traverse(folder("/"));